#coding=utf-8
"""
===========================
Author:杭州多测师_周sir
Time:2023/3/24 16:09
website:https://duoceshi.net
===========================
"""
from config.config import *
import time
import unittest
from public.utiles.HTMLTestRunnerNew import HTMLTestRunner
from public.utiles.mail import SendMail
import sys
#定义生成测试报告的路径及文件夹名称
now = time.strftime('%Y-%m-%d-%H-%M-%S')

filename = report_path+'\\'+str(now)+"_ui_report.html"
# print(filename)
def auto_run():
    discover = unittest.defaultTestLoader.discover(start_dir=testcase_path,
                                                   pattern='test_*.py')
    f  = open(filename,'wb')
    runner = HTMLTestRunner(stream=f,
                            title="cms后台系统ui自动化测试报告",
                            description='用例执行情况如下',
                            tester="小周")
    runner.run(discover)
    f.close()


def sendMail():
    sm  = SendMail(send_msg=filename,attachment=filename)
    sm.send_mail()
if __name__ == '__main__':
    auto_run()
    sendMail()
















